#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 1e5+50;

struct Room
{
	int p, c, id;
} r[N];

struct Person
{
	int a, b, id;
} p[N];

int n, m, l;

vector<int> ans[N];

int main(int argc, char const *argv[])
{
	scanf("%d%d%d", &n, &m, &l);
	for (int i=0; i<n; ++i)
	{
		scanf("%d%d", &r[i].p, &r[i].c);
		r[i].id = i;
	}
	for (int i=0; i<m; ++i)
	{
		scanf("%d%d", &p[i].a, &p[i].b);
		p[i].id = i;
	}
	sort(r, r+n, [](const Room &a, const Room &b){
		return a.p < b.p;
	});
	sort(p, p+m, [](const Person &a, const Person &b){
		return (a.a - a.b) > (b.a - b.b);
	});

	// for (int i=0; i<n; ++i)
	// 	dbg(i, r[i].id, r[i].p, r[i].c);
	LL res = 0;
	int now = 0;
	for (int i=0; i<m && p[i].a >= p[i].b; ++i)
	{
		// dbg(now, r[now].id, r[now].c, ans[r[now].id].size());
		ans[r[now].id].push_back(p[i].id);
		res += 1LL * p[i].b * l + 1LL * (p[i].a - p[i].b) * r[now].p;
		while ((int)ans[r[now].id].size() == r[now].c)
			++now;
	}
	now = n-1;
	for (int i=m-1; i>=0 && p[i].a < p[i].b; --i)
	{
		
		// dbg(now, r[now].id, r[now].c, ans[r[now].id].size());
		ans[r[now].id].push_back(p[i].id);
		res += 1LL * p[i].b * l + 1LL * (p[i].a - p[i].b) * r[now].p;
		while ((int)ans[r[now].id].size() == r[now].c)
			--now;
	}
	res <<= 1;
	printf("%lld\n", res);
	for (int i=0; i<n; ++i)
	{
		printf("%d", (int)ans[i].size());
		for (int x : ans[i])
			printf(" %d", x + 1);
		putchar('\n');
	}
	return 0;
}